from sqlalchemy import Column, Integer, String, Float, ForeignKey
from sqlalchemy.sql.schema import PrimaryKeyConstraint

from .score_database import Base
from sqlalchemy.orm import relationship

class Score(Base):
    __tablename__ = 'student_assessment_results'

    student_id = Column(Integer, ForeignKey("student_basic_information.student_id"), comment="学生编号")
    student_name = Column(String(20), nullable=True, comment="学生姓名(冗余)")
    class_name = Column(String(20), nullable=True, comment="学生班级(冗余)")  # 修正为字符串类型
    exam_sequence = Column(Integer, nullable=False, comment='考核序次')
    score = Column(Float, nullable=True, comment='分数')  # 修正为浮点型
    to_Score = relationship("Stu", backref="Stu2Score")

    # 复合主键：学生ID+考核序次
    __table_args__ = (
        PrimaryKeyConstraint('student_id', 'exam_sequence'),
    )

